<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@  taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<%@ include file="common/head.jsp"%>

<body class="fix-header fix-sidebar">

	<!-- Preloader - style you can find in spinners.css -->
	<div class="preloader">
		<svg class="circular" viewBox="25 25 50 50">
				<circle class="path" cx="50" cy="50" r="20" fill="none"
				stroke-width="2" stroke-miterlimit="10" /> </svg>
	</div>
	<!-- Main wrapper  -->
	<div id="main-wrapper">
		<!-- header header  -->
		<%@ include file="common/header.jsp"%>
		<!-- End header header -->
		<!-- Left Sidebar  -->
		<%@ include file="common/nav.jsp"%>
		<!-- End Left Sidebar  -->
		<!-- Page wrapper  -->
		<div class="page-wrapper">
			<!-- 锐高软件 -->
			<%@ include file="../common/ruigao.jsp"%>

			<!--
                    	作者：offline
                    	时间：2018-03-26
                    	描述：部门统计信息展示
                    -->
			<div class="container-fluid">

				<div class="row">

					<div class="col-lg-6">
						<div class="card">
							<div class="card-title">
								部门统计
								<hr>

								<%@ include file="listall/selectcompanyid.jsp"%>

								<div class="btn-group show">
									<button aria-expanded="false" data-toggle="dropdown"
										class="btn btn-light dropdown-toggle waves-effect"
										type="button">
										<font style="vertical-align: inherit;"><font
											style="vertical-align: inherit;"> 公司 </font></font><span
											class="caret m-l-5"></span>
									</button>
									<div class="dropdown-menu ">
										<c:forEach var="company" items="${CompanyList}">
											<a title="${company.companyId}" class="dropdown-item company">${company.companyName}

											</a>
										</c:forEach>
									</div>
									<input type="hidden" name="opt" id="opt" value=""> <input
										type="hidden" name="companyids" id="companyids"
										value="${companyid}">
								</div>





										<div class="btn-group ">
										<select class=" btn btn-light departs" id="val-depart" name="val-digits">
											<c:forEach var="depart" items="${DepartList}">
												<option class="dropdown-item company"
													value="${depart.deptId}">${depart.deptName}</option>
											</c:forEach>
										</select>
									</div>

								
	                             <div class="btn-group">
									<input type="month" class="btn btn-light waves-effect date"
										name="val-date" placeholder="yyyy-mm">
								</div>
                                 <hr>
								<form action="${pageContext.request.contextPath}/pageuserlist">
									
									 <div class="btn-group">
									 <input class="btn btn-light" style="float: right;" type="submit" id="bth" value="查看人员"> 
									
								    </div>
									
									<input type="hidden" id="companyidmorenid" name="companyidmoren"
										value=""> <input type="hidden" id="departidd"
										name="departidd" value="">
								</form>
								
								
								
								
								<input type="hidden" name="companyid" class="companyid" value="">
								<input type="hidden" name="opt" id="opt" value=""> <input
									type="hidden" name="method" id="method" value=""> <input
									type="hidden" name="opts" id="opts" value="">
							</div>
							<div class="card-content">
								<div id="basic-Pie" style="height: 370px"></div>
							</div>

						</div>

					</div>

					<div class="col-lg-6">
						<div class="card">
							<div class="card-title">
								<h4>部门员工列表</h4>

							</div>
							<div class="card-body">
								<div class="table-responsive">
									<table class="table table-hover ">
										<thead>
											<tr>
												<th>员工姓名</th>
												<th>性别</th>
												<th>职位</th>
											</tr>
										</thead>
										<tbody>
											<c:forEach var="us" items="${page.getPageList()}">
												<tr>
													<td>${us.userName}</td>

													<td><c:if test="${us.userSex eq 1 }">
                                                                                                                                 男
                                          </c:if> <c:if
															test="${us.userSex eq 2 }">
                                                                                                                               女  
                                          </c:if></td>

													<td><span class="badge badge-danger">
															${us.userPosition} </span></td>

												</tr>

											</c:forEach>
										</tbody>

									</table>

									<!--上一页--下一页-->
									<div class="table-responsive m-t-40">
										<div id="example23_wrapper" class="dataTables_wrapper">
											<div class="dataTables_paginate paging_simple_numbers"
												id="example23_paginate" id="pageshow">

												<a
													href="pageuserlist?PageNo=1&opt=newcompanyid&gongsiid=${gongsiid}&bumenid=${bumenid}"
													class="paginate_button" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23"> <font
													style="vertical-align: inherit;"> <font
														style="vertical-align: inherit;"></font>首页
												</font>

												</a>
												<c:if test="${page.getHasPrevPage() }">
													<a
														href="pageuserlist?PageNo=${page.getPrevPage()}&opt=newcompanyid&gongsiid=${gongsiid}&bumenid=${bumenid}"
														class="paginate_button previous disabled"
														aria-controls="example23" data-dt-idx="0" tabindex="0"
														id="example23_previous"><font
														style="vertical-align: inherit;"><font
															style="vertical-align: inherit;">上一页 </font></font> <input
														type="hidden" id="departid" name="departid" value="">

													</a>
												</c:if>

												<c:if test="${page.getHasNextPage() }">
													<a
														href="pageuserlist?PageNo=${page. getNextPage()}&opt=newcompanyid&gongsiid=${gongsiid}&bumenid=${bumenid}"
														class="paginate_button next" aria-controls="example23"
														data-dt-idx="7" tabindex="0" id="example23_next"><font
														style="vertical-align: inherit;"><font
															style="vertical-align: inherit;">下一页 </font></font> </a>
												</c:if>
												<a
													href="pageuserlist?PageNo=${page.getTotalPage()}&opt=newcompanyid&gongsiid=${gongsiid}&bumenid=${bumenid}"
													class="paginate_button" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23"> <font
													style="vertical-align: inherit;"> <font
														style="vertical-align: inherit;"></font>末页
												</font>
												</a>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>

				<!-- End PAge Content -->
			</div>

		</div>
	</div>
	<!-- End Container fluid  -->
	<!-- footer -->
	<%@ include file="common/footer.jsp"%>
	<!-- End footer -->
	<!-- End Page wrapper  -->
	<%@ include file="common/js.jsp"%>

	<script src="js/lib/echart/echarts-BuMen-init.js"></script>
	<script type="text/javascript">
		$(function() {
			//判断当前登录的员工的权限
			var competence = ${competence};
			if(competence!=3){
				$(".show").html("");
			}
			//初始化公司
			$("#opt").val("showdepart");
			var opt = $("#opt").val();
			var companyidmoren = parseInt($("#companyids").val());
			var companyids = $(".companyid").val();
			if (companyidmoren == 0 && companyids != 0) {
				companyidmoren = $(".companyid").val();
			} else {
				companyidmoren = parseInt($("#companyids").val());
			}

			$(".companyid").val(companyidmoren);
			$("#companyidmoren").val(companyidmoren);
			$("#companyidmorenid").val(companyidmoren);
			//$("#gongsiid").val(companyidmoren);
			$.ajax({
				url : "deptstatistics",
				data : {
					"companyidmoren" : companyidmoren,
					"opt" : opt
				},
				type : "GET",
				dataType : "JSON",
				success : function(data) {
					$(".departs").text("");
					for ( var i in data) {
						$(".departs").append(
								"<option value='"+data[i].deptId+"'>"
										+ data[i].deptName + "</option>");

					}
					//绑定部门的事件
					var options = $("#val-depart option:selected");
					var companyid = parseInt(options.val());
					$("#departidd").val(companyid);
				},
				error : function(data) {
					swal({
						title : '操作失败！',
						type : 'error',
						confirmButtonText : '确定',
						closeOnConfirm : false
					});
				}
			});

			//点击公司事件
			$(".company").click(
					function() {
						$("#opt").val("showdepartlist");
						var companytid = $(this).attr('title');
						$(".companyid").val(companytid);
						$("#companyidmoren").val(companytid);
						$("#companyidmorenid").val(companytid);
						//$("#gongsiid").val(companytid);						
						var companyidmoren = $(".companyid").val();
						var opt = $("#opt").val();

						$.ajax({
							url : "deptstatistics",
							data : {
								"companyidmoren" : companyidmoren,
								"opt" : opt
							},
							type : "GET",
							dataType : "JSON",
							success : function(data) {
								$(".departs").text("");
								for ( var i in data) {
									$(".departs").append(
											"<option value='"+data[i].deptId

+"'>"
													+ data[i].deptName
													+ "</option>");

								}

							},
							error : function(data) {
								swal({
									title : '操作失败！',
									typr : 'error',
									confirmButtonText : '确定',
									closeOnConfirm : FALSE
								});
							}
						});
					});

			//点击部门事件
			$("#val-depart ").change(function() {
				var options = $("#val-depart option:selected");
				var departid = parseInt(options.val()); //部门id
				$("#departidd").val(departid);
				//$("#departidd").val(departid);
			});

			//获取到下拉框选中的月份
			$("input").change(function() {
				$(".boolean").val("true");
				var echartData = "";
				$("#opt").val("selectechart");
				var options = $("#val-depart option:selected");
				var departid = parseInt(options.val());
				var method = $(".date").val();
				var companyid = parseInt($(".companyid").val());
				var opt = $("#opt").val();
				$.ajax({
					url : "deptechart",
					data : {
						"departid" : departid,
						"opt" : opt,
						"companyid" : companyid,
						"method" : method
					},
					type : "GET",
					dataType : "JSON",
					success : function(data) {
						if (data.Boolean == true) {
							echartData = data;
							initEcharts(echartData);
						} else {

							initEcharts(echartData);
							swal({
								title : '抱歉，该月没有数据！',
								type : 'error',
								confirmButtonText : '确定',
								closeOnConfirm : false
							});
						}
					},
					error : function(data) {
						swal({
							title : '数据加载失败！',
							type : 'error',
							confirmButtonText : '确定',
							closeOnConfirm : FALSE
						});
					}
				});
			});

		});
	</script>


</body>

</html>